package com.caine.androidtask.ls14;

import android.annotation.SuppressLint;
import android.telephony.SmsManager;
import android.util.Log;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Utils {
	public static final boolean DEBUG = true;
	public static final String TAG = "<Caine_Zhu>";
	public static final String OUTGOING_CALL = "android.intent.action.NEW_OUTGOING_CALL";
	private static boolean isAnswerCall = false;
	public static Date beginCall = null;
	public static String whats;
	public static String phoneNumber;

	public static String getPhoneNumber() {
		return phoneNumber;
	}

	public static void setPhoneNumber(String phoneNumber) {
		Utils.phoneNumber = phoneNumber;
	}

	public static boolean getIsAnswerCall() {
		return isAnswerCall;
	}

	public static void setIsAnswerCall(boolean isAnswerCall) {
		Utils.isAnswerCall = isAnswerCall;
	}

	@SuppressLint("SimpleDateFormat")
	public static String getLocaTime() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		return sdf.format(new Date());
	}

	// return seconds or minutes ?
	public static String longTime(Date startTime, Date endTime) {
		return longTime(startTime, endTime, false);
	}

	public static String longTime(Date startTime, Date endTime,
			boolean isReturnSeconds) {
		long taskTime = 0;
		taskTime = (endTime.getTime() - startTime.getTime()) / 1000;
		int hours = (int) taskTime / (60 * 60);
		int minutes = (int) (taskTime - hours * 60 * 60) / 60;
		int seconds = (int) taskTime - hours * 60 * 60 - minutes * 60;
		if(DEBUG)
		Log.e(TAG, (String) (isReturnSeconds == true ? taskTime
				: ((hours > 0 ? hours + "H" : "")
						+ (minutes > 0 ? minutes + "m" : "") + seconds + "s")));
		return (String) (isReturnSeconds == true ? taskTime
				: ((hours > 0 ? hours + "H" : "")
						+ (minutes > 0 ? minutes + "m" : "") + seconds + "s"));
	}
	
public static boolean sendMsg(String what,String targetNumber){
		
	    SmsManager smsManager = SmsManager.getDefault();
		smsManager.sendTextMessage(targetNumber, null, what, null, null);
		return true;
	}
}
